{% extends "admin/base.html" %}

{% load i18n admin_tags %}

{% block title %}{% trans "Automates" %}{% endblock %}

{% block content %}
    <div class="text-left">
        <h4 class="px-3">{% trans "Automates" %}</h4>
    </div>
    <form action="{% url list_url %}" method="post">
      {% csrf_token %}
        <div class="col-12 p-3">
            <a href="{% url 'admin:automate' %}" class="btn btn-success" role="button">{% trans "New" %}</a>
              <select name="action" required="">
                <option value="" selected="">---------</option>
                <option value="delete_selected">{% trans "Delete selected automates" %}</option>
              </select>
            <button class="btn btn-outline-dark mx-1" type="submit">{% trans "Go" %}</button>
        </div>

        <div class="col-12 p-3">
          {% if object_list|length > 0 %}
            <table class="table table-striped">
              <thead class="thead-dark">
                <tr class="text-uppercase">
                  <th>
                      <div id="checkbox_view">
                        <span class="mr-2"><input type="checkbox" id="action_toggle"></span>{% trans "Name" %}
                      </div>
                  </th>
                  <th>{% trans "Match" %}</th>
                  <th><i class="fa fa-folder text-warning mr-2"></i>{% trans "Destination Folder" %}</th>
                  <th>{% trans "Tags" %}</th>
                </tr>
              </thead>
              <tbody>
                {% for automate in object_list %}
                  <tr>
                    <td><span class="mr-2"><input type="checkbox" name="_selected_action" value="{{ automate.id }}" /></span><a href="{% url 'admin:automate_change' automate.id %}">{{ automate.name}}</a></td>
                    <td><span class="mr-2">{{automate.match}}</td>
                    <td><span class="mr-2">
                      <a href="{% url 'admin:browse' %}#{{ automate.dst_folder.id}}">{% tree_path automate.dst_folder %}</a>
                    </td>
                    <td>
                      <ul class="d-flex flex-row mb-0 pl-0">
                        {% tags_line automate %}
                      </ul>
                    </td>
                  </tr>
                {% endfor %}
              </tbody>
            </table>
          {% else %}
            {% trans "No automates defined so far" %}
          {% endif %}
      </div>
    </form>
{% endblock %}